package thread;

/*
 * @author zzr
 * @date: 2025/04/14  19:43
 * @description:
 */
public class Thread10 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                System.out.println("线程执行中");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    break;
                }
            }
            System.out.println("线程执行完毕");
        });
        System.out.println("线程开始执行");
        t.start();
        Thread.sleep(5000);
        t.interrupt();
    }
}
